< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03100700.xhp

(section: const) (bookmark: bm_id3146958)
Const statement

Const ステートメント

Const Statement [Runtime]
Const ステートメント [実行時](hd_id3146958.1)

Defines a string as a constant.
文字列を定数として定義します。(par_id3154143.2)

(/section: const)

Syntax:
構文:(hd_id3150670.3)

Const Text = Expression
Const Text = Expression(par_id3150984.4)

Parameters:
パラメータ:(hd_id3147530.5)

Text: Any constant name that follows the standard variable naming conventions.
Text: 定数名。命名規則は変数名のものと同じ。(par_id3153897.6)

A constant is a variable that helps to improve the readability of a program. Constants are not defined as a specific type of variable, but rather are used as placeholders in the code. You can only define a constant once and it cannot be modified. Use the following statement to define a constant:
定数は変数の一種であり、プログラムの可読性を向上させるために使用します。定数は、特定の型の変数として定義されるわけではなく、コード中に存在する一種のプレースホルダとして使用されます。各定数の定義は 1 度だけが可能で、定義後に変更することはできません。定数の定義は、下記のステートメントで行います。(par_id3147264.7)

CONST ConstName=Expression
CONST ConstName=Expression(par_id3150542.8)

The type of expression is irrelevant. If a program is started, Office Basic converts the program code internally so that each time a constant is used, the defined expression replaces it.
型宣言は不要です。 型宣言は不要です。プログラムを実行すると、定数が使われているコード行を読み込むごとに、Office Basic が内部的な変換処理を行い、定義部で指定した表式に個々の定数を置き換えます。(par_id3150400.9)

Example:
例:(hd_id3154366.10)

Sub ExampleConst
Sub ExampleConst(par_id3145420.11)

Const iVar = 1964
Const iVar = 1964(par_id3154217.12)

Msgbox iVar
Msgbox iVar(par_id3156281.13)

Const sVar = "Program", dVar As Double = 1.00
Const sVar = "Program", dVar As Double = 1.00(par_id3153969.14)

Msgbox sVar & " " & dVar
Msgbox sVar & " " & dVar(par_id3149560.15)

end sub
end sub(par_id3153368.16)


< Prev / Next >